using System;

namespace Unified {
	public class Streams {
		public Streams() {
		}

		public static string ConvertStreamToString(System.IO.MemoryStream Stream) {
			byte[] d =ConvertStreamToBytes(Stream);
			if(d==null) return "";
			return System.Text.ASCIIEncoding.ASCII.GetString(d);
		}
		public static byte[] ConvertStreamToBytes(System.IO.MemoryStream Stream) {
			if(Stream==null) return null;
			if(Stream!=null&&Stream.CanSeek&&Stream.Position>0) Stream.Position=0;
			byte[] d = new byte[(int)Stream.Length];
			Stream.Read(d, 0, d.Length);
			Stream.Close();
			return d;
		}
		public static System.IO.MemoryStream ConvertStringToStream(string Data) {
			return ConvertBytesToStream(System.Text.ASCIIEncoding.ASCII.GetBytes(Data));
		}
		public static System.IO.MemoryStream ConvertBytesToStream(byte[] Data) {
			return new System.IO.MemoryStream(Data);
		}
	}
}
